package com.timebank.score.controller;

import com.timebank.common.core.web.pojo.AjaxResult;
import com.timebank.common.security.annotation.RequiresLogin;
import com.timebank.score.pojo.entity.ScoreTaskType;
import com.timebank.score.service.ScoreTaskTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 积分任务类型 控制层
 * @author shiliuyinzhen
 */
@RestController
@RequestMapping("/taskType")
@Api(tags = "积分任务类型相关接口")
public class ScoreTaskTypeController {

    @Resource
    private ScoreTaskTypeService scoreTaskTypeService;

    /**
     * 查询积分任务类型列表
     * @param scoreTaskType
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询积分任务类型列表")
    public AjaxResult getScoreTaskTypeList(ScoreTaskType scoreTaskType){
        return scoreTaskTypeService.getScoreTaskTypeList(scoreTaskType);
    }

    /**
     * 新增积分任务类型
     * @param scoreTaskType
     * @return
     */
    @RequiresLogin
    @PostMapping
    @ApiOperation("新增积分任务类型")
    public AjaxResult addScoreTaskType(@RequestBody ScoreTaskType scoreTaskType){
        return scoreTaskTypeService.addScoreTaskType(scoreTaskType);
    }

    /**
     * 修改积分任务类型
     *
     * @param typeId
     * @param scoreTaskType
     * @return
     */
    @RequiresLogin
    @PutMapping("/{typeId}")
    @ApiOperation("修改积分任务类型")
    public AjaxResult updateScoreTaskType(@PathVariable("typeId") Integer typeId
            ,@RequestBody ScoreTaskType scoreTaskType){
        scoreTaskType.setTypeId(typeId);
        return scoreTaskTypeService.updateScoreTaskType(scoreTaskType);
    }

    /**
     * 批量删除积分任务类型
     * @param typeIds
     * @return
     */
    @DeleteMapping("/{typeIds}")
    @ApiOperation("批量删除积分任务类型")
    public AjaxResult batchDeleteScoreTaskType(@PathVariable("typeIds") Integer[] typeIds){
        return scoreTaskTypeService.batchDeleteScoreTaskType(typeIds);
    }
}
